from selenium import webdriver

from tinyshop_ui.common.login import common_login
from tinyshop_ui.common.input import common_input
from tinyshop_ui.common.findmodule import common_module
from tinyshop_ui.common.img import common_img
from tinyshop_ui.common.button import common_button


class automodule:
    def webinstall(self,parm1,parm2,ls):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_button(webd)
        common_img(webd)
        common_input(webd).text(webd,ls)
        common_input(webd).submit()
        webd.close()

    def otherinstall(self,parm1,parm2,ls):
        webd = common_login().webd
        common_module(webd,parm1,parm2)
        common_button(webd)
        common_input(webd).checkbox()
        common_input(webd).submit()
        webd.close()

    def Emailinstall(self,parm1,parm2,ls):
        webd=common_login().webd
        common_module(webd,parm1,parm2)
        common_input(webd).text(webd,ls)
        common_button(webd)
        common_input(webd).submit()
        webd.close()



automodule().webinstall('系统设置','站点设置','123456678789')
automodule().otherinstall('系统设置','其它配置','56756757600')
automodule().Emailinstall('系统设置','邮箱配置','99999999999')

class handmodule:
    def __init__(self):
        self.driver=webdriver.Firefox()
        self.driver.get('http://192.168.0.220/TinyShop_v2.4/index.php?con=admin&act=login')
        self.driver.maximize_window()
        self.driver.find_element_by_name('name').send_keys('admin')
        self.driver.find_element_by_name('password').send_keys('123456')
        self.driver.find_element_by_name('verifyCode').send_keys('aaaa')
        self.driver.find_element_by_class_name('button').click()

    def pingpaiguanli(self):
        self.driver.find_element_by_link_text('商品中心').click()
        self.driver.find_element_by_link_text('品牌管理').click()
        self.driver.find_element_by_link_text('添加').click()
        self.driver.find_element_by_name('name').send_keys('123')
        self.driver.find_element_by_name('url').send_keys('http://www.baidu.com')
        self.driver.find_element_by_name('sort').send_keys('6')
        self.driver.find_element_by_xpath('/html/body/div[3]/div[2]/form/div/div[1]/div[1]/dl[4]/dd/button').click()
        self.driver.switch_to.frame('Openupimg_dialog')
        self.driver.find_element_by_name('upfile').send_keys('C:\\Users\\Administrator\\Desktop\\black-earth.jpg')


    def zhutishezhi(self):

        self.driver.find_element_by_link_text('主题设置').click()
        self.driver.find_element_by_id('default').click()

    def guanlishouye(self):

        self.driver.find_element_by_class_name('btn').click()

    def xinximoban(self):

        self.driver.find_element_by_link_text('信息模板').click()
        self.driver.find_element_by_link_text('编辑').click()
        self.driver.find_element_by_class_name('button').click()

    def tixingguanli(self):

        self.driver.find_element_by_link_text('提醒管理').click()
        self.driver.find_element_by_link_text('邮件').click()
        self.driver.find_element_by_xpath('/html/body/div[2]/div[2]/div/form/dl[3]/dd/input').send_keys('8798hiuhiuh')
        self.driver.find_element_by_class_name('button').click()

    def kaifangdenglv(self):

        self.driver.find_element_by_link_text('第三方整合').click()
        self.driver.find_element_by_link_text('开放登录').click()
        self.driver.find_element_by_link_text('编辑').click()
        self.driver.find_element_by_class_name('normal').send_keys('oijuiojoi908098097')
        self.driver.find_element_by_name('app_secret').click()
        self.driver.find_element_by_name('app_secret').send_keys('8778')

        self.driver.find_element_by_class_name('focus_button').click()

    def zhifufangshi(self):

        self.driver.find_element_by_link_text('支付与配送').click()
        self.driver.find_element_by_link_text('支付方式').click()
        self.driver.find_element_by_xpath('/html/body/div[3]/div[2]/div/ul/li[2]').click()

    def quyuhuafen(self):

        self.driver.find_element_by_link_text('支付与配送').click()
        self.driver.find_element_by_link_text('区域划分').click()
        self.driver.find_element_by_link_text('添加').click()
        self.driver.find_element_by_id('zoning_name').click()
        self.driver.find_element_by_id('zoning_name').send_keys('蜗牛学院')
        self.driver.find_element_by_class_name('areas ').click()
        self.driver.find_element_by_class_name('button').click()
        self.driver.find_element_by_link_text('全选').click()
        self.driver.find_element_by_link_text('删除').click()
        self.driver.find_element_by_class_name(' aui_state_highlight').click()
        self.driver.find_element_by_link_text('刷新').click()

    def kuaidigongsi(self):

        self.driver.find_element_by_link_text('支付与配送').click()
        self.driver.find_element_by_link_text('快递公司').click()
        self.driver.find_element_by_link_text('全选').click()
        self.driver.find_element_by_link_text('删除').click()
        self.driver.find_element_by_class_name(' aui_state_highlight').click()
        self.driver.find_element_by_link_text('刷新').click()

    def yunfeimoban(self):

        self.driver.find_element_by_link_text('支付与配送').click()
        self.driver.find_element_by_link_text('运费模板').click()
        self.driver.find_element_by_link_text('添加').click()
        self.driver.find_element_by_name('name').click()
        self.driver.find_element_by_name('name').send_keys('手动化模板')
        self.driver.find_element_by_xpath('/html/body/div[3]/div[2]/div/form/dl[2]/dd/input[2]').click()
        self.driver.find_element_by_xpath('/html/body/div[3]/div[2]/div/form/dl[2]/dd/input[2]').send_keys('999')
        self.driver.find_element_by_name('second_price').click()
        self.driver.find_element_by_name('second_price').send_keys('999')
        self.driver.find_element_by_id('add_area').click()
        self.driver.find_element_by_link_text('编辑').click()
        self.driver.find_elements_by_class_name('button').click()

    def guanliyuan(self):

        self.driver.find_element_by_link_text('安全管理').click()
        self.driver.find_element_by_link_text('管理员').click()
        self.driver.find_element_by_link_text('添加').click()
        self.driver.find_element_by_name('name').click()
        self.driver.find_element_by_name('name').send_keys('自动添加管理员')
        self.driver.find_element_by_name('password').click()
        self.driver.find_element_by_name('password').send_keys('123456')
        self.driver.find_element_by_name('repassword').click()
        self.driver.find_element_by_name('repassword').send_keys('123456')
        self.driver.find_element_by_class_name('button').click()















